<#import "/manage/tpl/pageBase.ftl" as page>
<@page.pageBase currentMenu="贫困人员管理">
<style>
	.td_right{text-align: right;}
</style>
<script type="text/javascript">

    $(document).ready(function(){
        $("#address").click(function(){
            $("#hiddens").slideToggle("slow");
            $("#hiddenss").slideToggle("slow");
        });
    });

    function changeProvince(){
        var selectVal = $("#province").val();
        $("#provinceName").val($("#province").find("option:selected").text());
        if(!selectVal){
            console.log("return;");
            return;
        }
        var _url = "${basepath}/manage/order/selectCitysByProvinceCode?provinceCode="+selectVal;
        console.log("_url="+_url);
        $("#citySelect").empty().show().append("<option value=''>--选择城市--</option>");
//        $("#areaSelect").empty().hide().append("<option value=''>--选择区域--</option>");
        $.ajax({
            type: 'POST',
            url: _url,
            data: {},
            dataType: "json",
            success: function(data){
                //console.log("changeProvince success!data = "+data);
                $.each(data,function(index,value){
                    //console.log("index="+index+",value="+value.code+","+value.name);
                    $("#citySelect").append("<option value='"+value.code+"'>"+value.name+"</option>");
                });
            },
            error:function(er){
                console.log("changeProvince error!er = "+er);
            }
        });
    }

    function changeCity(){
        var selectProvinceVal = $("#province").val();
        var selectCityVal = $("#citySelect").val();
        $("#cityName").val($("#citySelect").find("option:selected").text());
//        if(!selectProvinceVal || !selectCityVal){
//            console.log("return;");
//            return;
//        }
        var _url = "${basepath}/manage/order/selectAreaListByCityCode?provinceCode="+selectProvinceVal+"&cityCode="+selectCityVal;
        console.log("_url="+_url);
        $("#areaSelect").empty().show().append("<option value=''>--选择区域--</option>");
        $.ajax({
            type: 'POST',
            url: _url,
            data: {},
            dataType: "json",
            success: function(data){
                //console.log("changeProvince success!data = "+data);
                $.each(data,function(index,value){
                    //console.log("index="+index+",value="+value.code+","+value.name);
                    $("#areaSelect").append("<option value='"+value.code+"'>"+value.name+"</option>");
                });
            },
            error:function(er){
                console.log("changeCity error!er = "+er);
            }
        });
    }
    function areaCity(){
        $("#areaName").val($("#areaSelect").find("option:selected").text());
    }

    function handleAddPovertyUser(){
        var _url = "handleAddPovertyUser";
        $.ajax(_url,{
            type: 'POST',
            data: $('#form').serialize(),
            success: function(data){
                alert("添加扶贫用户成功");
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
                alert("操作失败，请稍后重试!");
            }
        });
    }

    function q(){
        var s = $("#province").find("option:selected").text()
                + $("#citySelect").find("option:selected").text()
                + $("#areaSelect").find("option:selected").text()
                + $("#add").val();
        $("#address").val(s);
    }


	$(function() {
		 $("#username").focus();
	});
</script>
</head>

<body>
<#if e.id??>
    <#assign formAction="111">
<#assign insertAction=false />
<#else >
<#assign formAction="insert">
    <#assign insertAction=true />
</#if>

<#--<%-- formAction=<s:property value="#formAction"/><br> --%>-->
<#--<%-- formAction2=<s:property value="#request.formAction"/><br> --%>-->
<form action="${basepath}/manage/poverty/doEditUser" id="form" method="post">
	<#--<s:form action="user!" namespace="/" theme="simple" id="form">-->
		<table class="table table-bordered">
			<tr>
				<td colspan="2" style="background-color: #dff0d8;text-align: center;">
					<strong>修改贫困人员信息</strong>
				</td>
			</tr>
			<tr style="display:none;">
				<th>id</th>
				<td><input type="hidden" name="id" value="${e.id!""}"></td>
			</tr>
			<tr>
				<th class="td_right" style="padding-top: 15px">姓名</th>
				<td style="text-align: left;">
                    <#if insertAction>
                        <input type="text" name="name" id="name">
                    <#else >
                        <input type="text" name="name" id="name" value="${e.name!""}">
                    </#if>
				</td>
			</tr>

            <tr>
                <th class="td_right" style="padding-top: 15px">性别</th>
                <td style="text-align: left;">
                    <select name="gender" id="gender">
                        <option vlaue="1">${e.gender!"--请选择--"}</option>
                        <option vlaue="2">男</option>
                        <option vlaue="3">女</option>
                    </select>
                </td>
            </tr>

            <tr>
                <th class="td_right" style="padding-top: 15px">手机号</th>
                <td style="text-align: left;">
                    <#if insertAction>
                        <input type="text" name="phone" id="phone"  data-rule="手机号:required;phone;length[11];remote[unique]">
                    <#else >
                        <input type="text" name="phone" id="phone" value="${e.phone!""}">
                    </#if>
                </td>
            </tr>

            <tr>
                <th class="td_right" style="padding-top: 15px">开户银行</th>
                <td style="text-align: left;">
                    <#if insertAction>
                        <input type="text" name="bankName" id="bankName">
                    <#else >
                        <input type="text" name="bankName" id="bankName" value="${e.bankName!""}">
                    </#if>
                </td>
            </tr>

            <tr>
                <th class="td_right" style="padding-top: 15px">银行账号</th>
                <td style="text-align: left;">
                    <#if insertAction>
                        <input type="text" name="bankNumber" id="bankNumber">
                    <#else >
                        <input type="text" name="bankNumber" id="bankNumber" value="${e.bankNumber!""}">
                    </#if>
                </td>
            </tr>


            <#--<tr>-->
                <#--<th class="td_right">地址区域</th>-->
                <#--<td>-->
                    <#--<input type="hidden"  name="province" value="" id="provinceName"/>-->
                    <#--<select onchange="changeProvince()" name="provinceCode" id="province">-->
                            <#--<option value="">--选择省份--</option>-->
                        <#--<#list provinces as item>-->
                            <#--<option value="${item.code}">${item.name}</option>-->
                        <#--</#list>-->
                    <#--</select>-->

                    <#--<input type="hidden"  name="city" value="" id="cityName"/>-->
                    <#--<select onchange="changeCity()" id="citySelect" name="cityCode">-->
                            <#--<option value="">--选择城市--</option>-->
                    <#--</select>-->

                    <#--<input type="hidden" name="area" value="郑州市" id="areaName"/>-->
                    <#--<select onchange="areaCity()" id="areaSelect" name="areaCode">-->
                            <#--<option value="">--选择区域--</option>-->
                    <#--</select>-->
                <#--</td>-->
            <#--</tr>-->

            <tr>
                <th class="td_right" style="padding-top: 15px">地址</th>
                <td style="text-align: left;">
								<textarea type="text" style="width: 300px;" readonly="readonly"
                                          id="address" name="address" placeholder="请输入详细地址">${e.address!""}</textarea>
                </td>
            </tr>

        <tr id="hiddens" style="display:none;">
        <th class="td_right" style="padding-top: 15px">地址区域</th>
        <td>
        <input type="hidden"  name="province" value="" id="provinceName"/>
        <select onchange="changeProvince()" name="provinceCode" id="province">
        <option value="">--选择省份--</option>
        <#list provinces as item>
        <option value="${item.code}">${item.name}</option>
        </#list>
        </select>

        <input type="hidden"  name="city" value="" id="cityName"/>
        <select onchange="changeCity()" id="citySelect" name="cityCode">
        <option value="">--选择城市--</option>
        </select>

        <input type="hidden" name="area" value="郑州市" id="areaName"/>
        <select onchange="areaCity()" id="areaSelect" name="areaCode">
        <option value="">--选择区域--</option>
        </select>
        </td>
        </tr>
            <tr id="hiddenss" style="display:none;">
                <th class="td_right" style="padding-top: 15px">写入详细地址</th>
                <td style="text-align: left;">
								<textarea type="text" style="width: 300px;" onblur="q()"
                                          id="add" name="add" placeholder="请输入详细地址">${e.address!""}</textarea>
                </td>
            </tr>

            <tr>
                <th class="td_right" style="padding-top: 15px">具体描述</th>
                <td style="text-align: left;">
                    <textarea type="text" style="width: 300px;" name="familyInfo" id="familyInfo"
                           placeholder="请输入详细地址" >${e.familyInfo!""}</textarea>
                </td>
            </tr>




			<tr>
				<td colspan="2" style="text-align: center;">

                        <input type="submit" class="btn btn-success" value="确认修改"/>
                    <input type="button"  class="btn btn-success" onclick="javascript:history.back(-1);" value="返回"/>

				</td>
			</tr>
		</table>

</form>
</@page.pageBase>